<!DOCTYPE html>
<html>

<head>
	<title>{$title}</title>
    <meta charset="utf-8">
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="initial-scale=1, width=device-width, maximum-scale=1, user-scalable=no">
	<meta name="viewport" content="initial-scale=1.0,user-scalable=no,maximum-scale=1" media="(device-height: 568px)">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-touch-fullscreen" content="yes">
	<meta name="full-screen" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="format-detection" content="telephone=no">
	<meta name="format-detection" content="address=no">
	
	<!-- import CSS -->
	<link rel="stylesheet" href="{$Think.config.site.resource_url}css/assets/style.css?11">
	<script src="{$Think.config.site.resource_url}js/assets/jquery.js"></script>

</head>

<body>	
<!-- 顶部 -->
<div class="head">
	<div class="head_back"><a onClick="javascript :history.back(-1);"><img src="{$Think.config.site.resource_url}images/assets/arrow.png"></a></div>
    <div class="head_txt">机柜管理</div>
</div>

<div class="flow_btn">
	<a href="/home/Charecabinet/bindPage?sid={$seller_id}" class="flow_a flow_btn3 fr">绑定机柜</a>
</div>

<div class="store_main">
	<ul class="showMoreNChildren" pagesize="10">
		{volist name="charecabinets" id="v"}
		<li>
			<div class="store_head">
				<div class="store_h_left">机柜ID：{$v.cabinet_id}</div>
				<span class="state_normal">{$v.status}</span>
			</div>
			<div class="store_con">
				<p class="store_p mt10">归属商户：{$v.name}</p>
				<p class="store_p"><span>型号：{$v.model}</span><span>总数：{$v.devicenum}块</span><span>可租：{$v.surplus}块</span></p>
			</div>			
			<div class="sotre_btn">
				<a href="/home/Charecabinet/delete?id={$v.id}&sid={$v.seller_id}" class="sotre_btn1 state_default">删除</a>
				<a href="/home/Charecabinet/detail?id={$v.id}" class="sotre_btn1">查看详情</a>
			</div>	
		</li>
		{/volist}
	</ul>
</div>

<div id='showMorehandle' ><span>已经到底了</span></div>

<script>
    (function () {
        var showMoreNChildren = function ($children, n) {
            //显示某jquery元素下的前n个隐藏的子元素
            var $hiddenChildren = $children.filter(":hidden");
            var cnt = $hiddenChildren.length;
            for ( var i = 0; i < n && i < cnt ; i++) {
                $hiddenChildren.eq(i).show();
            }
            return cnt-n;//返回还剩余的隐藏子元素的数量
        }

        //对页中现有的class=showMorehandle的元素，在之后添加显示更多条，并绑定点击行为
        $(".showMoreNChildren").each(function () {
            var pagesize = $(this).attr("pagesize") || 10;
            var $children = $(this).children();
            if ($children.length > pagesize) {
                for (var i = pagesize; i < $children.length; i++) {
                    $children.eq(i).hide();
                }

                $("<div class='showMorehandle' ><span>显示更多</span></div>").insertAfter($(this)).click(function () {
                    if (showMoreNChildren($children, pagesize) <= 0) {
                        //如果目标元素已经没有隐藏的子元素了，就隐藏“点击更多的按钮条”
                        $(this).hide();
                        $('#showMorehandle').show();
                    };
                });
            }
        });
    })();

    function backFunc(data) {
        if(data.res == 1) {
            alert_success(data.msg);
            setTimeout(function(){window.location.reload();}, 1000);
        }else{
            alert_fail(data.msg);
        }
    }
</script>